#include "FbxAnimation.h"

namespace GC
{
	GC::FbxAnimation::FbxAnimation(const FbxAnimStack* a_animStack, const double a_deltaFrameTime, FbxNode* a_rootNode)
		: m_name( a_animStack->GetName() )
	{		
		const double f_animationLength = a_animStack->GetLocalTimeSpan().GetDuration().GetSecondDouble();
		//Need to +1 because length / delta gives frames - 1
		m_frameCount = (int)(f_animationLength / a_deltaFrameTime) + 1;

		const int f_layersCount = a_animStack->GetMemberCount<FbxAnimLayer>();

		m_layers.reserve( f_layersCount );

		for ( int i = 0; i < f_layersCount; ++i)
		{
			FbxAnimLayer* f_animLayer = a_animStack->GetMember<FbxAnimLayer>(i);

			GC::FbxAnimationLayerPtr f_layer = std::make_shared<FbxAnimationLayer>(f_animLayer, a_rootNode, a_deltaFrameTime );

			m_layers.push_back( f_layer );			
		}		
	}

	const FbxString GC::FbxAnimation::GetName() const
	{
		return m_name;
	}
	const int GC::FbxAnimation::GetFrameCount() const
	{
		return m_frameCount;
	}

	const GC::VectorFbxAnimationLayerPtr GC::FbxAnimation::GetLayers() const
	{
		return m_layers;
	}

	const size_t GC::FbxAnimation::GetLayersSize() const
	{
		return m_layers.size();
	}

}
